package com.lyl.momanapp.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.lyl.momanapp.R;
import com.lyl.momanapp.adapter.MFragmentPagerAdapter;
import com.lyl.momanapp.frament.OrderOne;
import com.lyl.momanapp.util.view.MyBaseActivity;

/**
 * Created by lyl on 2017/10/17.
 */

public class UserOrderActivity  extends MyBaseActivity{
    private String[] tatle;
    private Fragment[] fragmentsList;
    private TabLayout mTab;
    private ViewPager mVP;
    private  int  num=0;
    @Override
    public void initUI() {
        setContentView(R.layout.activity_user_order);

        mTab = ((TabLayout) findViewById(R.id.user_order_tab));
        mVP = ((ViewPager) findViewById(R.id.user_order_vp));
        Bundle bundle = this.getIntent().getExtras();
        //接收name值
        num = bundle.getInt("name");
//        mTab = ((TabLayout) findViewById(R.id.user_order_tab));
//        mVP = ((ViewPager) findViewById(R.id.user_order_vp));
    }   

    @Override
    public void initData() {
        tatle = new String[]{"全部", "待付款", "待发货", "待收货", "售后"};
        fragmentsList = new Fragment[]{new OrderOne(), new OrderOne(), new OrderOne(), new OrderOne(), new OrderOne()};
    }

    @Override
    public void addListeners() {
        findViewById(R.id.fanhui).setOnClickListener(this);
        findViewById(R.id.zhuye).setOnClickListener(this);
        mVP.setAdapter(new MFragmentPagerAdapter(getSupportFragmentManager(), fragmentsList, tatle));
        mTab.setupWithViewPager(mVP);
        mTab.getTabAt(num).select();
    }
    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.fanhui:{
                finish();
            }
            break;
            case R.id.zhuye: {

                startActivity(new Intent(UserOrderActivity.this, MainActivity.class));
                finish();
            }
        }
    }

}
